package com.itgungnir.designpattern.prototype;

import java.util.HashMap;
import java.util.Map;

public class ShapeCache {
	private Map<String, Shape> shapes;

	public ShapeCache() {
		loadCache();
	}

	private void loadCache() {
		shapes = new HashMap<>();
		shapes.put("circle", new Circle());
		shapes.put("rectangle", new Rectangle());
		shapes.put("triangle", new Triangle());
	}

	public Shape getShape(String id) {
		Shape shape = shapes.get(id);
		return (Shape) shape.clone();
	}
}
